home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / VISUALBA / 2PAWS.ZIP / PAWS2.BAS next >
BASIC Source File  |  1994-03-01  |  4KB  |  160 lines

  1. '********************************PAWS2.BAS*******************************
  2. 'This program will run in the QuickBASIC environment and you can make
  3. 'stand-alone *.EXE files that permit you to use a mouse in a DOS program.
  4. 'When you start QuickBASIC, you MUST load the Quick Library QB.QLB
  5. 'so that you can CALL INTERRUPT.
  6. '
  7. 'The command is:
  8. 'QB/L QB.QLB
  9. '
  10. 'I have called this PAWS2.BAS (and the executable program PAWS2.COM)
  11. 'because it has two (2) PAUSE commands, keyboard and mouse.
  12. '
  13. 'Please... please... no applause for the PAWS2 play on words as I
  14. 'am sure you know that a mouse has paws too (2?).
  15. '
  16. 'This is a giant step forward, not for mankind, but for mouse users that
  17. 'want that mouse for QuickBASIC use.
  18. '
  19. 'John De Palma on CompuServe 76076,571
  20. '
  21. '12/30/93
  22. '
  23. DEFINT A-Z
  24. CONST False = 0
  25. CONST True = NOT False
  26.  
  27. 'interrupt call for both INTERRUPT and INTERRUPTX
  28. TYPE RegType
  29.      ax    AS INTEGER
  30.      bx    AS INTEGER
  31.      cx    AS INTEGER
  32.      dx    AS INTEGER
  33.      bp    AS INTEGER
  34.      si    AS INTEGER
  35.      di    AS INTEGER
  36.      flags AS INTEGER
  37.      ds    AS INTEGER
  38.      es    AS INTEGER
  39. END TYPE
  40.  
  41. DECLARE SUB MouseFunction (m1%, m2%, m3%, m4%)
  42. DECLARE SUB IsMouse (Yes%)
  43. DECLARE SUB SetCursor (row%, col%)
  44. DECLARE SUB ClearBuffer ()
  45. DECLARE SUB ButtonStatus (m1%, m2%, m3%, m4%)
  46. DECLARE SUB ShowCursor (Hide%)
  47. DECLARE SUB HideCursor (Hide%)
  48.  
  49. 'executable code below
  50. COLOR 15, 1
  51. CLS
  52. DEF FnCenter (text$) = 41 - (LEN(text$) \ 2)
  53. SCREEN 0
  54. WIDTH 80
  55.  
  56. CALL IsMouse(Yes%)
  57.    
  58.     IF Yes% THEN
  59.         PRINT "CLICK! or Press a key to Continue...";
  60.         row = CSRLIN
  61.         col = POS(0)
  62.         CALL SetCursor(row, col)
  63.         ClearBuffer
  64.         DO
  65.             CALL ButtonStatus(m1, m2, m3, m4)
  66.         LOOP UNTIL LEN(INKEY$) OR m2 <> 0
  67.         CALL HideCursor(Hide%)
  68.     ELSE
  69.         PRINT "Press a Key to Continue...";
  70.         ClearBuffer
  71.         WHILE INKEY$ = "": WEND
  72.     END IF
  73.  
  74. SUB ButtonStatus (m1, m2, m3, m4)
  75.     m1 = 3
  76.     CALL MouseFunction(m1, m2, m3, m4)
  77.  
  78. END SUB
  79.  
  80. SUB ClearBuffer
  81. WHILE INKEY$ <> "": WEND
  82. END SUB
  83.  
  84. SUB HideCursor (Hide%)
  85.     m1 = 2
  86.     CALL MouseFunction(m1, 0, 0, 0)
  87.     Hide% = Hide% + 1             'have to show cursor one more than
  88. END SUB                           'this number to see the cursor again
  89.  
  90. 'tests for Mouse Software installed then Mouse Hardware.
  91. SUB IsMouse (Yes%)
  92.     Yes% = True
  93.     DEF SEG = 0
  94.    
  95.     MouseSegment& = 256& * PEEK(207) + PEEK(206)
  96.     MouseOffset& = 256& * PEEK(205) + PEEK(204)
  97.  
  98.     DEF SEG = MouseSegment&
  99.  
  100.     IF (MouseSegment& = 0 AND MouseOffset& = 0) OR PEEK(MouseOffset&) = 207 THEN
  101.         Yes% = False
  102.         MouseChecked = True
  103.         DEF SEG
  104.         text$ = "Can't Find Mouse-Driver -> SOFTWARE!"
  105.         LOCATE 2, FnCenter(text$)
  106.         PRINT text$
  107.         EXIT SUB
  108.     END IF
  109.    
  110.     m1 = 0                          'mouse reset and status
  111.     CALL MouseFunction(m1, m2, 0, 0)
  112.     IF m1 THEN
  113.         text$ = "A -" + LTRIM$(STR$(m2)) + "- BUTTON mouse is present"
  114.         LOCATE 2, FnCenter(text$)
  115.         PRINT text$
  116.         CALL ShowCursor(Hide%)      'show cursor
  117.     ELSE
  118.         text$ = "Can't find Mouse-Driver - HARDWARE or Software!"
  119.         LOCATE 2, FnCenter(text$)
  120.         PRINT text$
  121.         Yes% = False
  122.     END IF
  123. END SUB
  124.  
  125. SUB MouseFunction (m1%, m2%, m3%, m4%)
  126.    
  127.     DIM Regs AS RegType
  128.  
  129.     Regs.ax = m1
  130.     Regs.bx = m2
  131.     Regs.cx = m3
  132.     Regs.dx = m4
  133.  
  134.     CALL INTERRUPT(&H33, Regs, Regs)
  135.  
  136.     m1 = Regs.ax
  137.     m2 = Regs.bx
  138.     m3 = Regs.cx
  139.     m4 = Regs.dx
  140.  
  141. END SUB
  142.  
  143. SUB SetCursor (row%, col%)
  144.     m1 = 4
  145.     m3 = (col% * 8) - 1
  146.     m4 = (row% * 8) - 1
  147.     CALL MouseFunction(m1, 0, m3, m4)
  148.  
  149. END SUB
  150.  
  151. SUB ShowCursor (Hide%)
  152.    
  153.     FOR i = Hide% TO Hide% + 1           'have to show once more than hide
  154.         m1 = 1                           'ie, hide cursor twice, show thrice
  155.         CALL MouseFunction(m1, 0, 0, 0)
  156.     NEXT
  157.  
  158. END SUB
  159.  
  160.